from django.shortcuts import render
from django.views.generic import TemplateView,DetailView
from users.forms import SignIn,SignUp
from  .models import PictureShow
from contact.models import C_Contact
from comment.models import Comments

# Create your views here.

class Index(TemplateView):
    template_name = 'index.html'
    login =SignIn()
    signup = SignUp()
    pictureshow = PictureShow.objects.all()

    def get_context_data(self, **kwargs):
        kwargs['mlogin'] = self.login
        kwargs['msignup'] = self.signup
        kwargs['pictureshow'] = self.pictureshow
        kwargs['kind1'] = PictureShow.objects.filter(kind__name='kind1')
        kwargs['kind2'] = PictureShow.objects.filter(kind__name='kind2')
        kwargs['kind3'] = PictureShow.objects.filter(kind__name='kind3')


        return super().get_context_data(**kwargs)


class Comment(DetailView):
    template_name = 'blog_post.html'
    model = PictureShow
    context_object_name = 'picture'
    login = SignIn()
    signup = SignUp()

    def get_context_data(self, **kwargs):
        kwargs['mlogin'] = self.login
        kwargs['msignup'] = self.signup
        kwargs['user_comments'] = Comments.objects.filter(picture__id=kwargs['object'].pk).order_by('-comment_time')
        return super().get_context_data(**kwargs)

class Kind1(TemplateView):
    template_name = 'portfolio1.html'
    login =SignIn()
    signup = SignUp()

    def get_context_data(self, **kwargs):
        kwargs['mlogin'] = self.login
        kwargs['msignup'] = self.signup
        kwargs['kind'] = PictureShow.objects.filter(kind__name='kind1')

        return super().get_context_data(**kwargs)

class Kind2(TemplateView):
    template_name = 'portfolio1.html'
    login =SignIn()
    signup = SignUp()

    def get_context_data(self, **kwargs):
        kwargs['mlogin'] = self.login
        kwargs['msignup'] = self.signup
        kwargs['kind'] = PictureShow.objects.filter(kind__name='kind2')

        return super().get_context_data(**kwargs)

class Kind3(TemplateView):
    template_name = 'portfolio1.html'
    login =SignIn()
    signup = SignUp()

    def get_context_data(self, **kwargs):
        kwargs['mlogin'] = self.login
        kwargs['msignup'] = self.signup
        kwargs['kind'] = PictureShow.objects.filter(kind__name='kind3')

        return super().get_context_data(**kwargs)
